package com.frp.client.config;

import com.frp.lib.client.ClientControl;
import com.frp.lib.config.ClientCommon;
import com.frp.lib.config.ClientProperties;
import com.frp.lib.config.ProxyModel;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by hujianjun on 11/23 0023.
 */
@Configuration
public class ClientConfig {
    @Bean
    @ConfigurationProperties(prefix = "common")
    ClientCommon clientCommon() {
        return new ClientCommon();
    }

    @Bean
    @ConfigurationProperties(prefix = "proxy")
    Map<String, ProxyModel.ProxyDefine> proxyMap() {
        return new HashMap<String, ProxyModel.ProxyDefine>();
    }

    @Bean
    @ConfigurationProperties(prefix = "")
    ClientProperties clientProperties() {
        return new ClientProperties();
    }

    @Bean(initMethod = "init")
    ClientControl clientControl(ClientProperties properties, ClientCommon clientCommon, Map<String, ProxyModel.ProxyDefine> proxyMap) {
        ClientControl clientControl = new ClientControl();
        clientControl.setProperties(properties);
        return clientControl;
    }
}
